<?php

declare(strict_types=1);

namespace Plugin\Attractions\AttractionManagement\Model;

use Hyperf\DbConnection\Model\Model as MineModel;

/**
 * @property int $id 主键
 * @property string $title 标题
 * @property string $intro 活动简介
 * @property int $group 信息分组
 * @property int $type_id 活动类型Id
 * @property int $spot_id 活动点位id
 * @property int $status 状态1正常2停止,优先级高于时间控制
 * @property string $limit 活动限制
 * @property integer $sort 排序
 * @property \Carbon\Carbon $start_time 开始时间
 * @property \Carbon\Carbon $end_time 结束时间
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class AttractionInfo extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'attraction_info';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['title', 'intro', 'group', 'type_id', 'spot_id', 'cover_id', 'status', 'sort', 'start_time', 'end_time', 'extension'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'group' => 'integer', 'type_id' => 'integer', 'cover_id' => 'string', 'status' => 'integer', 'sort' => 'integer', 'start_time' => 'datetime', 'end_time' => 'datetime', 'extension' => 'array'];

    public function type()
    {
        return $this->hasOne(AttractionType::class, 'id', 'typeId');
    }

    public function spot()
    {
        return $this->hasOne(AttractionSpot::class, 'id', 'spotId');
    }

    public function tags()
    {
        return $this->hasMany(AttractionInfoTag::class, 'info_id', 'id');
    }
}